//
//  ZYCTeaLeaveRecordFlowChartSectionHeaderView.m
//  ZDSC
//
//  Created by 张威 on 2021/11/9.
//

#import "ZYCTeaLeaveRecordFlowChartSectionHeaderView.h"
#import "ZYCTeaLeaveFlowChartModel.h"
@interface ZYCTeaLeaveRecordFlowChartSectionHeaderView ()

/** 头像背景*/
@property (nonatomic, strong) UIView *iconBgView;
/** 头像*/
@property (nonatomic, strong) UIImageView *iconView;
/** 文字*/
@property (nonatomic, strong) UILabel *titleLabel;
/** 时间*/
@property (nonatomic, strong) UILabel *timeLabel;

@end
@implementation ZYCTeaLeaveRecordFlowChartSectionHeaderView

- (void)setModel:(ZYCTeaLeaveFlowChartModel *)model{
    _model = model;
    _titleLabel.text = model.applyNode;
    if ([model.nodeType integerValue] == 2) {
        _timeLabel.text = model.applyStatus;
    }else{
        _timeLabel.text = model.applyTime;
    }

}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = HEX_RGB(@"FFFFFF");
        [self addSubview:self.iconBgView];
        [self addSubview:self.iconView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.timeLabel];
        
        [self.iconBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15.0f);
            make.centerY.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(20.0f, 20.0f));
        }];
        
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.iconBgView);
            make.size.mas_equalTo(CGSizeMake(10.0f, 10.0f));
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconBgView.mas_right).offset(15.0f);
            make.centerY.equalTo(self.iconBgView);
        }];
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-15.0f);
            make.centerY.equalTo(self.iconBgView);
        }];
    }
    return self;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 15.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 13.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _timeLabel;
}


- (UIView *)iconBgView {
    if (!_iconBgView) {
        _iconBgView = [[UIView alloc] init];
        _iconBgView.backgroundColor = HEX_RGB(@"BFC7D0");
        _iconBgView.layer.cornerRadius = 10.0f;
        _iconBgView.layer.masksToBounds = YES;
        
    }
    return _iconBgView;
}

- (UIImageView *)iconView {
    if (!_iconView) {
        _iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shenpi"]];
        _iconView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _iconView;
}

@end
